<!--<link rel="stylesheet" href="${request.contextPath}/lib/plugins/zTree3/css/zTreeStyle/zTreeStyle.css">-->
<link rel="stylesheet" href="${request.contextPath}/lib/asmpWorkCss/ZtreeInput.css">
<!-- 用户编辑模态框 -->
<!--<link rel="stylesheet" href="${request.contextPath}/lib/plugins/select2/select2.min.css">-->
<div class="modal-body">
    <form class="form-horizontal"  method="post" name="form_action" id="form_action" action="${request.contextPath}/soa/org/datas/save">
        <input type="hidden" id="id" name="id" value="${model.id!}">
        <input type="hidden" id="parentOrgId" name="parentOrgId" value="${model.parentOrgId!}">

        <!--<input type="hidden" id="orgCode" name="orgCode" value="123456789">-->
        <input type="hidden" id="orgBriefName" name="orgBriefName" value="jgjc">

        <div class="form-group">
            <label for="orgName" class="col-sm-4 control-label">部门名称</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" id="orgName" name="orgName" placeholder="部门名称" value="${model.orgName!}">
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    var dataAuthorId;
    var dataAuthorStr;
    $(document).ready(function(){
        $('#form_action').bootstrapValidator({
            message: 'This value is not valid',
            container: 'tooltip',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                orgName: {
                    container: 'popover',
                    message: 'The nickName is not valid',
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        }
                    }
                }
            }
        }).on('success.form.bv', function(e) {
            dialogEdit.title('正在提交..');
            var orgId=$("#ztreeInputOrg").attr("data_id");
            var pId=$("#ztreeInputOrg").attr("parent");
            if(orgId!=null&&pId!=null){
                $('#cityId').val(orgId);
                $('#provinceId').val(pId);
            }
            ajaxSubmit($('#form_action')[0], function(data){

                treeRefresh(nodeEdit);
                dialogEdit.close().remove();
                var x = dialog({
                    content : data.msg
                });
                x.show();
                setTimeout(function() {
                    x.close().remove();
                }, 2000);

            });
        });

        $(".dataAuthor").on('click', function () {
            post("/soa/china/allChina", "html", {"parentOrgId":$("#parentOrgId").val()}, function (obj) {
                layerIndex = layer.open({
                    type: 1,
                    title: "选择权限范围",
//                closeBtn: false,
                    area: '700px;',
                    shade: 0.8,
                    content: obj, //注意，这里是一个页面
                    btn:['保存'],
                    yes:function(){
                        $("#dataAuthor").val(dataAuthorId);
                        $("#dataAuthorStr").val(dataAuthorStr);
                        layer.close(layerIndex);
                    }
                });
            });
        });
        SelectMany(contextPath+"/soa/org/datas/box/orgType",{"pid":$("#parentOrgId").val()},"#orgTypeSelect","#orgType");
    });

    //负责人下拉
    selectcbx(
            contextPath+"/soa/user/datas/userSelect",
            "#leaderId",
            {
                "cmd":0,
                "oid":0,
            }
    );
    function SelectMany(comboxUrl,params,SelectTarget,hiddenId) {
        $.ajax({
            url: comboxUrl,
            type: "post",
            dataType: "json",
            data:params,
            async: false,
            success: function (result) {
                for (var i = 0; i < result.length; i++) {
                    // console.log(result[i]);
                    var $option = $('<option/>').attr('value', result[i].id).html(result[i].name);
                    $option.appendTo($(SelectTarget));
                }

                $(SelectTarget).select2({
                    placeholder: "请选择",
                    allowClear: false
                }).change(function () {
                    var hiddenTypeId = $(hiddenId);
                    var zhi = $(SelectTarget).val();
                    hiddenTypeId.attr("value", zhi);
                });

            }
        });
        var hiddenIdValue = $(hiddenId).val();
        if (hiddenIdValue != null && hiddenIdValue != "") {
            $(SelectTarget).val(hiddenIdValue).trigger("change");
        }
    }
</script>
<script>

    var leaderId = ${model.leaderId};
    if (leaderId != null && leaderId != 0) {
        $("#leaderId").val(leaderId).trigger("change");
    }
    //区域下拉框
//    var orgSelectedVal=$("#cityId").val();
//    //var orgSelectedVal=$("#ztreeInputOrg").attr("data_id");
//    if(orgSelectedVal!=null&&orgSelectedVal!=""){
//        var zTree = $.fn.zTree.getZTreeObj("areaZtree");
//        var node = zTree.getNodeByParam("id",orgSelectedVal,null);
//        //console.log("cityId="+orgSelectedVal+"node="+node);
//        var parentName=node.getParentNode()!=null&&node.pId!=1?node.getParentNode().name:'';
//        $("#ztreeInputOrg").val(parentName+node.name);
//        //$("#ztreeInputOrg").val(node.name);
//    }
    //comboxUrl ajax请求,hidd

</script>